<input type="hidden" id="signin_status" value="<?php echo $this->session->flashdata('signin_status'); ?>" />
<input type="hidden" id="sign_up_status" value="<?php echo $this->session->flashdata('sign_up_status'); ?>" />
<script type="text/javascript">
  $(document).ready(function() {
    var signin_status = $.trim($('#signin_status').val());
    if (signin_status == 2) {
      toastr.error('Invalid login details !');
    }
    var sign_up_status = $.trim($('#sign_up_status').val());
    if (sign_up_status == 4) {
      toastr.success('Successfully activated your account !');
    }
    if (sign_up_status == 5) {
      toastr.error('Error occured. Try again !');
    }
  });
</script>
<div class="container" style="min-height: 500px;">
  <div class="row">
    <div class="span6 offset2">
      <div class="login" style="float: right;">
        <form class="form-horizontal" method="post" action="<?php echo base_url('signin'); ?>">
          <input type="hidden" name="csrf_token" value="<?php echo set_csrf_token(); ?>"/>
          <?php if (!empty($redirect_url)) { ?>
            <input type="hidden" name="redirect_url" value="<?php echo $redirect_url; ?>"/>
          <?php } ?>
          <?php if (!empty($api_token)) { ?>
            <input type="hidden" name="api_token" value="<?php echo $api_token; ?>"/>
          <?php } ?>          
          <div class="control-group">
            <div class="controls">
              <h4>Sign In</h4>
            </div>
          </div>
          <div class="control-group">
            <label for="inputEmail" class="control-label">Email / Username</label>
            <div class="controls">
              <input id="inputEmail" type="text" placeholder="Email / Username" name="username" <?php if (empty($username)) { ?> autofocus="true" <?php } ?> value="<?php echo $username; ?>"/>
            </div>
          </div>
          <div class="control-group">
            <label for="inputPassword" class="control-label">Password </label>
            <div class="controls">
              <input id="inputPassword" type="password" placeholder="Password" name="password" <?php if (!empty($username)) { ?> autofocus="true" <?php } ?>/>
            </div>
          </div>
          <div class="control-group">
            <div class="controls">
              <?php if (!empty($app_data)) { ?>
                <input class="btn" type="submit" value="Authorize App"/>
              <?php } else { ?>
                <input class="btn" type="submit" value="Sign In"/>
              <?php } ?>
            </div>
          </div>
          <?php if (!empty($app_data)) { ?>
            <div align="center" style="color: tomato; width: 400px;">
              <?php echo 'Grant permission for "<b>' . $app_data['app_name'] . '</b>" to access your profile'; ?>
            </div>
          <?php } ?>
        </form>
      </div>
    </div>
  </div>
</div>